qinglan.Canvas.ParBulletFactory = qinglan.Canvas.BulletFactory.extend(function(){

}).methods({
	init: function(){
		this.spellCard = this.opt.spellCard;

		this.trajectory = this.opt.trajectory;

		this.tween = this.opt.tween;

		this.bullet = this.opt.bullet;
	},
	setOption: function(opt){
		this.supr(opt);
		this.init();
	},
	createBullets: function(opt, wayNum, from, delay) {
		var bullets = [];
		var id = 0;
		for (var i = 0; i < opt.num; i++){
			var bullet = new qinglan.Canvas.ParBullet('#parBullet' + wayNum + (++id), this.bullet.position,{
				img: this.bullet.img,
				theta: from.theta,
				distance: from.distance,
				initPos: this.bullet.initPos,
				delay: (i * delay)
			});
			bullets.push(bullet);
		}
		return bullets;
	},
	createTrajectorys: function(opt){
		var parTrajectorys = [];
		var id = 0;
		for (var i = 0; i < opt.way; i++){
			var parTrajectory = new qinglan.Canvas.ParTrajectory('#parTrajectory' + this.opt.id + (++id));
			var from = qinglan.Extend.simple({},this.trajectory.from,1);
			var map = qinglan.Extend.simple({},this.trajectory.map,1);
			parTrajectory.setOption({
				from: from,
				map: map
			});
			
			var dataMap = opt.mode.call(null, opt, i, parTrajectory.getOption());
			var parHelper = this.createHelper(this.tween, dataMap.from, dataMap.map);
			parTrajectory.setBulletHelper(parHelper);
		
			parTrajectory.addBullets(this.createBullets(opt, i, dataMap.from, this.tween.delay));
			parTrajectorys.push(parTrajectory);
		}

		return parTrajectorys;
	},
	createHelper: function(tween, from, map) {
		var parHelper = new qinglan.Canvas.ParBulletHelper('#ParBulletHelper'+this.opt.id, tween);
		parHelper.setMap(from, map);
		return parHelper;
	},
	createSpellCard: function(){
		var spellCard = new qinglan.Canvas.ParSpellCard('#ParSpellCard'+this.opt.id);
		spellCard.setOption(this.spellCard);
		spellCard.addTrajectorys(this.createTrajectorys(spellCard.getOption()));

		return spellCard;
	}
}).statics({

});
